package Java学习.字符串;

public class 字符串比较 {
    public static void main(String[] args) {
    int[] num={1,2,3};
    String str=new StringBuilder(string(num)).replace(string(num).length()-1,string(num).length(),"").append("]").toString();
        System.out.println(str);
    }
    //定义方法把数组变成字符串
    public static String string(int[] num){
        //定义一个空字符串
        String str="";
        str+="[";
        for (int i = 0; i < num.length; i++) {
            str+=num[i]+",";
        }
        return str;
    }
}
